class Stack:
    def __init__(self):
        self.items = []

    def push(self, item):
        self.items.append(item)

    def pop(self):
        if not self.is_empty():
            return self.items.pop()
        return None

    def is_empty(self):
        return len(self.items) == 0

def decimal_to_octal(decimal):
    """十进制转八进制"""
    if decimal == 0:
        return "0"
    stack = Stack()
    while decimal > 0:
        remainder = decimal % 8  # 取8的余数
        stack.push(remainder)
        decimal = decimal // 8
    octal = ""
    while not stack.is_empty():
        octal += str(stack.pop())
    return octal

# 测试
if __name__ == "__main__":
    print(decimal_to_octal(10))  # 输出: 12
    print(decimal_to_octal(8))   # 输出: 10
    print(decimal_to_octal(0))   # 输出: 0